package com.hksj.gas.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hksj.common.core.model.Rest;
import com.hksj.gas.dto.GasAlarmDTO;
import com.hksj.gas.service.GasAlarmService;
import com.hksj.gas.vo.GasAlarmCountRankVO;
import com.hksj.gas.vo.GasAlarmListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "医气监测-医气设备报警管理")
@RequestMapping("/gas/gasDeviceAlarm")
@RestController
public class GasAlarmController {

    @Autowired
    private GasAlarmService gasAlarmService;

    @ApiOperation(value = "分页查询报警设备",response = GasAlarmListVO.class)
    @PostMapping("/queryDeviceAlarmByPage")
    public Rest<IPage<GasAlarmListVO>> queryDeviceAlarmByPage(@RequestBody GasAlarmDTO dto){
        return Rest.ok(gasAlarmService.queryDeviceAlarmByPage(dto));
    }

    @ApiOperation(value = "查询设备报警次数排名")
    @PostMapping("/queryAlarmCountRank")
    public Rest<List<GasAlarmCountRankVO>> queryAlarmCountRank(@RequestBody GasAlarmDTO dto){
        return Rest.ok(gasAlarmService.queryAlarmCountRank(dto));
    }

    @ApiOperation(value = "导出医用气体报警信息")
    @PostMapping("/exportAlarmDevice")
    public void exportAlarmDevice(@RequestBody GasAlarmDTO dto , HttpServletResponse response){
        gasAlarmService.exportAlarmDevice(dto,response);
    }

}
